
package com.seekting.study;

import java.util.Stack;

public class SaveRestore {

    float value = 1;

    Stack<Float> mValues = new Stack<Float>();

    public void alpha(float value) {
        this.value = this.value * value;

    }

    public void save() {

        mValues.push(value);
    }

    public void restore() {

        this.value = mValues.pop();
    }

    public void printVlaue() {
        System.out.println(String.format("value %s", value));
    }

    public static void main(String[] args) {

        SaveRestore saveRestore = new SaveRestore();
        saveRestore.printVlaue();
        saveRestore.save();
        {
            saveRestore.alpha(0.5f);
            saveRestore.printVlaue();
            saveRestore.save();
            {
                saveRestore.alpha(0.3f);
                saveRestore.printVlaue();
            }
            saveRestore.restore();
            saveRestore.printVlaue();
        }
        saveRestore.restore();
        saveRestore.printVlaue();
    }
}
